package org.softmed.rest.generation.classmanager;

import com.google.inject.Inject;

import groovy.lang.GroovyClassLoader;

public class ClassManager {

	@Inject
	static GroovyClassLoader groovyClassLoader;

	public synchronized static Class forName(String name)
			throws ClassNotFoundException {

		Class type = null;
		try {
			type = Class.forName(name);
			return type;

		} catch (Throwable t) {

			type = groovyClassLoader.loadClass(name);
			return type;
		}

	}

	public static GroovyClassLoader getGroovyClassLoader() {
		return groovyClassLoader;
	}

	public static void setGroovyClassLoader(GroovyClassLoader groovyClassLoader) {
		ClassManager.groovyClassLoader = groovyClassLoader;
	}

}
